package cn.itcast.controler;

import cn.itcast.PermissionService;
import cn.itcast.pojo.PageResult;
import cn.itcast.pojo.Permission;
import cn.itcast.pojo.QueryPageBean;
import cn.itcast.pojo.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkpermission")
public class CheckpermissionController {
    @Reference
    private PermissionService permissionService;

    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean pageBean) {
        PageResult pageResult = permissionService.findPage(pageBean);
        return pageResult;
    }

    @RequestMapping("/findById")
    public Result findById(@RequestParam("id") Integer permissionId) {
        try {
            Permission permission= permissionService.findById(permissionId);
            return new Result(true,"",permission);
        } catch (Exception e) {
            return new Result(false,"编辑权限失败");
        }

    }
}
